using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Data;
using System.Text;
using ResaGest.Metier.Reservation;
using ResaGest.DAO;
using ResaGest.Metier.Critere;


namespace ResaGest.DAO
{
    class reservationDAO
    {
		public static List<Reservation> getAllResaByCritere(ReservationCritere critere)
		{
			List<Reservation> lc = new List<Reservation>();
			string sqlCritere = "";
			if (critere.Client.Id != 0)
			{
				sqlCritere += "client_id = " + critere.Client.Id+ " and ";
			}
			if (critere.Datedeb != null)
			{
				sqlCritere += "datedeb_resa = " + critere.Datedeb+ " and ";
			}
			if (critere.Datefin!= null)
			{
				sqlCritere += "datefin_resa = " + critere.Datefin + " and ";
			}
			if (critere.Hotel.Id != 0 )
			{
				sqlCritere += "hotel_id = " + critere.Hotel.Id+ " and ";
			}

			string requete = "";
			requete += sqlCritere != "" ? "select * from Hotel where " + sqlCritere.Substring(0, sqlCritere.LastIndexOf("and")) : "select * from Chambre";


			requSQL requ = new requSQL(requete);
			List<object> list = requ.getList();
			DataRow dr;
			Reservation resa = new Reservation();
			for (int i = 0; i < list.Count; i++)
			{
				/*dr = (DataRow)list[i];
				resa = dr["Balcon_chambre"].ToString() == "0" ? false : true;
				ch.Hotel_id = (int)dr["Hotel_id"];
				ch.Id = (int)dr["id_chambre"];
				ch.Lit_id = (int)dr["Lit_id"];
				ch.Occupee = dr["Occupee"].ToString() == "0" ? false : true;
				ch.Prix_journalier = Convert.ToSingle(dr["Prix_journalier"]);
				ch.Taille = (int)dr["Taille"];
				ch.Type_chambre_id = (int)dr["Type_chambre_id"];
				ch.Type_sdb_id = (int)dr["Type_sbd_id"];
				lc.Add(ch);
				ch = new Chambre();*/
			}


			return lc;


		}
    }
}
